package com.imashimaro.annotation;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.imashimaro.serializer.BigDecimalSerializer;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.BigDecimal;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@JacksonAnnotationsInside
@JsonSerialize(using = BigDecimalSerializer.class)
public @interface BigDecimalFormat {
    /**
     * 保留小数位数,默认2位
     * @return
     */
    int scale() default 2;

    /**
     * 取整策略
     * @return
     */
    int model() default BigDecimal.ROUND_HALF_UP;

    /**
     * 是否转为字符串类型
     * @return
     */
    boolean isToString() default false;
}
